#!/bin/bash
# Script to restart the current Desktop Environment without rebooting the system.
# Thanks to this script you would not need to remember commands for each DE.

xprop_session=$(xprop -id $(xprop -root -notype | awk '$1=="_NET_SUPPORTING_WM_CHECK:"{print $5}') | grep _NET_WM_NAME | awk '{print $3}' | tr -d '"')

if [[ "$DESKTOP_SESSION" =~ "lxqt" ]]; then
	killall lxqt-panel && lxqt-panel &
elif [[ "$DESKTOP_SESSION" =~ "openbox" ]]; then
	openbox --restart &
elif [[ "$DESKTOP_SESSION" =~ "plasma" ]]; then
	kquitapp5 plasmashell && kstart5 plasmashell &
elif [[ "$DESKTOP_SESSION" =~ "gnome" ]]; then
	killall -3 gnome-shell && gnome-shell --replace &
elif [[ "$DESKTOP_SESSION" =~ "mate" ]]; then
	mate-panel --replace &
elif [[ "$xprop_session" =~ "JWM" ]]; then
	jwm -restart &
elif [[ "$xprop_session" =~ "Mutter(Budgie)" ]]; then
	budgie-panel --replace &
else
	echo "Error: The DE currently running is not yet supported"
fi
